/**
 * 
 */
package com.yerba.ricecooker.chart;

import java.util.ArrayList;

/**
 * @author mxie
 * 
 */
public class AnnotatedTimeLineDataRow
{
    public AnnotatedTimeLineDataRow(int numberOfUnits)
    {
        setNumberOfUnits(numberOfUnits);
    }

    String date;
    int dateYear;
    int dateMonth;
    int dateDay;

    int numberOfUnits = 0;
    ArrayList<Double> units = new ArrayList<Double>();

    public void addDataToRow(double value)
    {
        units.add(Double.valueOf(value));
    }

    public double getDataRow(int index)
    {
        return units.get(index).doubleValue();
    }

    public String getDate()
    {
        return date;
    }

    public void setDate(String date)
    {
        this.date = date;
        parseDate(getDate());
    }

    public int getDateYear()
    {
        return dateYear;
    }

    public void setDateYear(int dateYear)
    {
        this.dateYear = dateYear;
    }

    public int getDateMonth()
    {
        return dateMonth;
    }

    public void setDateMonth(int dateMonth)
    {
        this.dateMonth = dateMonth;
    }

    public int getDateDay()
    {
        return dateDay;
    }

    public void setDateDay(int dateDay)
    {
        this.dateDay = dateDay;
    }

    public int getNumberOfUnits()
    {
        return numberOfUnits;
    }

    public void setNumberOfUnits(int numberOfUnits)
    {
        this.numberOfUnits = numberOfUnits;
    }

    public ArrayList<Double> getUnits()
    {
        return units;
    }

    public void setUnits(ArrayList<Double> units)
    {
        this.units = units;
    }

    private void parseDate(String date)
    {
        try
        {
            this.setDateYear(Integer.parseInt(date.substring(0, 4)));
            this.setDateMonth(Integer.parseInt(date.substring(5, 7)));
            this.setDateDay(Integer.parseInt(date.substring(8, 10)));
        }
        catch (Exception e)
        {
            System.out.println("Exception: error parsing date [" + date + "]");
            System.out.println("Exception: " + e.getStackTrace());
        }
    }

}
